#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
char s[17000000];
bool vis[17000000];
int num[200];
int main()
{
	int n,nc,ans;
	while(scanf("%d %d",&n,&nc)!=EOF)
	{
		scanf(" %s",s);
		ans = 0;
		int sign = 0;
		memset(vis,false,sizeof(vis));
		memset(num,-1,sizeof(num));
		int len =strlen(s);
		for(int i =0;i<len&&sign<nc;i++)
		{
			if(num[s[i]]==-1)
			{
				num[s[i]] = sign++;
			}
		}
		for(int i = 0;i<=len-n;i++)
		{
			int temp = 0;
			for(int j = i;j<i+n;j++)
			{
				temp = temp*nc+(num[s[j]]);
			}
			if(!vis[temp])
			{
				vis[temp]=true;
				ans++;
			}
		}
		printf("%d\n",ans);
	}
} 
